<%request.setAttribute("pageName",new String("login"));%><%@include file="/include/header.jsp" %><% 
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
String openIDLocation = "https://www.google.com/accounts/o8/site-xrds?hd=";
String thisURL = request.getRequestURI();

Set<String> attributes = new HashSet();

if (user == null) 
{
	 Logger log = Logger.getLogger("loginPage");
	 
	if(request.getParameter("userdomain")!=null)
	{
		log.warning(userService.createLoginURL(UrlUtils.getHomeUrl(request),null,openIDLocation+request.getParameter("userdomain"),attributes));

		response.sendRedirect(userService.createLoginURL(UrlUtils.getHomeUrl(request),null,openIDLocation+request.getParameter("userdomain"),attributes));
	}else{
		out.print("<form> <h3> For Google Apps users, enter your domain name on Google Apps (my-company.com):<input type='text' name='userdomain' > <input type='submit' value='Login'></h3></form>");	
		String gmaiLoginUrl = userService.createLoginURL(request.getRequestURI(), null, "google.com/accounts/o8/id", attributes);
		out.print("<br><h3> For Gamil <a href='"+gmaiLoginUrl+"'>account</a></h3>");	

	}
	
} 
else 
{

	out.print("<hr>!  You can <a href='" +
    userService.createLogoutURL(thisURL) +
    "'>sign out</a>.</p>");
}
%>

<%@include file="/include/footer.jsp" %>

